﻿/******************************************************************************
* File description: BoxFailureInfo.qml
* Function: 实验故障弹窗
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.0
import "../components"

CustomPopupBox {
    title: "提示"

    height: 340*dp
    width: 580*dp

    property var failureInfoList: []

    property int showContinueButton: 0      // 0是  1否   2确定   4终止实验

    contentItem: Item{

        Rectangle{
            x: 20*dp; y: 10*dp
            width: parent.width - 2*x;  height: parent.height - y - 90*dp
            radius: 5*dp
            color: "#FEF4F3"
            border.color: "#E69393"
            Item{                    //  标题行
                x: 20*dp; y: 20*dp
                height: 30*dp; width: parent.width - 2*x
                CustomImage{
                    height: 20*dp; width: 20*dp
                    x: 5*dp; y: 5*dp
                    source: "qrc:/picture/bell.png"
                }Text{
                    text: qsTr("故障信息")
                    font.pixelSize: config.fontsize_1
                    font.bold: true
                    anchors.verticalCenter: parent.verticalCenter
                    x: 40*dp
                }
            }
            ListView{       // 内容信息
                x: 20*dp; y: 60*dp
                clip: true
                height: parent.height - y - 10*dp
                width: parent.width - 2*x
                model: failureInfoList.length
                delegate: Text{
                    text: failureInfoList[index]
                    height: 30*dp; width: parent.width
                    verticalAlignment: Text.AlignVCenter
                    elide: Text.ElideRight
                    font.pixelSize: config.fontsize
                }
            }
        }

        Row{
            x: 30*dp; y: parent.height - 60*dp
            height: 40*dp
            spacing: 16*dp
            anchors.horizontalCenter: parent.horizontalCenter
            CustomButton{
                visible: showContinueButton === 0 || showContinueButton === 1
                title: "停止实验"
                button_color: "#FF9478"
                text_color: "white"
                button_color_hover: "#F9815F"
                onClicked: {
                    box_opEndExp.startWait01()
                    box_opEndExp.show()
                    close()
                    failureInfoList = []
                    showContinueButton = 0
                    CommunicationMethod.operationExperiment(2)

                }
            }
            CustomButton{
                visible: showContinueButton === 0
                title: "继续实验"
                defaultMode1: true
                onClicked: {
                    close()
                    failureInfoList = []
                    showContinueButton = 0
                    CommunicationMethod.operationExperiment(7)
                }
            }
            CustomButton{
                visible: showContinueButton === 2
                defaultMode2: true
                title: "确定"
                onClicked: {
                    close()
                    failureInfoList = []
                    showContinueButton = 0
                }
            }
            CustomButton{
                visible: showContinueButton === 3
                title: "终止实验"
                button_color: "#FF9478"
                text_color: "white"
                button_color_hover: "#F9815F"
                onClicked: {
                    close()
                    CommunicationMethod.forcedStop()
                }
            }

        }
    }
}
